productList()
function productList (){
    function getUrlParams() {
        let href = location.href;
        let regExp = /.+\?(.+)/
    
        let param = regExp.exec(href)
        if (!param) {
            return
        }
    
        param = param[1]
        // console.log(param);
        // console.log(decodeURI(param));
        let paramArr = param.split("&");
        // console.log(paramArr);
        let query = {}
        paramArr.forEach(item => {
             let itemArr = item.split("=");
            // console.log(itemArr);
            query[itemArr[0]] = decodeURI(itemArr[1])
        })
    
        return query
    }
    
    let query = getUrlParams()
    console.log(query);
    
    
    
    
    let shopTitle =document.getElementById('shopNavTitle')
    shopTitle.innerText=query.brandName
    
    ajax({
        url: 'http://chst.vip:1234/api/getproduct',
        data: {
            productid: query.productId
        }
    }).then(res => {
        res = res.result[0]
        // console.log(res.bjShop);
        renderRecImg(res)
    })
    

    // 评论
    ajax({
        url: 'http://chst.vip:1234/api/getproductcom',
        data: {
            productid: query.productId
        }
        
    }).then(res => {
        res = res.result
        console.log(res);
        renderComment(res)
    })
    
    function renderRecImg(res) {
        let html = `
        
        <ul class="commentList">
        <li>${res.productImg}</li>
        <li>${res.productName}</li>
        <li>
            <span>当前最低&nbsp;￥7777</span>
            <span>优选评论&nbsp;9999条</span>
        </li>
        <li>
        ${res.bjShop}
        </li>
        </ul>
        `
        let recImg = document.querySelectorAll('.recImg')[0]
    
        recImg.innerHTML = html
        console.log(recImg);
    }

    // 评论
    let recMainContent = document.getElementsByClassName('recommen-main-content')[0]
    console.log(recMainContent);
    function renderComment(res) {
        let html = ''
        for (let i = 0; i < res.length; i++) {
            html += `
    
            <ul class="commentList">
            <li>
                <span>${res[i].comName}</span>
                <span>${res[i].comTime}</span>
            </li>
            <li>
            ${res[i].comContent}
            </li>
            <li>${res[i].comFrom}</li>
           </ul>
    
            `
        }
        recMainContent.innerHTML = html
    }
    
    
    
}